package mk.company.fin.utils;

/**
 * Utility class.
 * 
 * @author vlado.gjorgjiev
 */
public class CoreUtils {

	private CoreUtils() {
		// utility class
	}
	
	
	/**
	 * Returns the mapping code for the given konto character.
	 * The codes start from 0 to {@link AppUtils#KONTO_VALID_CHARACTERS_COUNT}.
	 * If the result code is not in the given boundaries then the character is not
	 * valid for konto representation.
	 * @param kontoCharMappingValue the konto character to process.
	 * @return mapping code (from 0 to {@link AppUtils#KONTO_VALID_CHARACTERS_COUNT}
	 */
	public static int getKontoCharMappingCode(char kontoCharMappingValue) {
		int result = -1;
		switch (kontoCharMappingValue) {
			case '0':
				result = 0;
				break;
			case '1':
				result = 1;
				break;
			case '2':
				result = 2;
				break;
			case '3':
				result = 3;
				break;
			case '4':
				result = 4;
				break;
			case '5':
				result = 5;
				break;
			case '6':
				result = 6;
				break;
			case '7':
				result = 7;
				break;
			case '8':
				result = 8;
				break;
			case '9':
				result = 9;
				break;
		}
		return result;
	}
	
	/**
	 * Returns the mapping value for the given konto mapping code.
	 * This is reverse from the {@link AppUtils#getKontoCharMappingCode(char)}.
	 * @param kontoCharMappingCode the konto code to process.
	 * @return mapping value
	 */
	public static char getKontoCharMappingValue(int kontoCharMappingCode) {
		char result = ' ';
		switch (kontoCharMappingCode) {
		case 0:
			result = '0';
			break;
		case 1:
			result = '1';
			break;
		case 2:
			result = '2';
			break;
		case 3:
			result = '3';
			break;
		case 4:
			result = '4';
			break;
		case 5:
			result = '5';
			break;
		case 6:
			result = '6';
			break;
		case 7:
			result = '7';
			break;
		case 8:
			result = '8';
			break;
		case 9:
			result = '9';
			break;
		}
		return result;
	}
}
